import requests


class APIClient:
    def __init__(self, base_url=None, api_key=None, headers=None):
        self.base_url = base_url
        self.api_key = api_key
        self.headers = headers or {}

        if self.api_key:
            self.headers["Authorization"] = f"Bearer {self.api_key}"

    def request(self, method, endpoint, payload=None, stream=False):
        url = f"{self.base_url}/{endpoint}" if endpoint else self.base_url
        return requests.request(method, url, json=payload, headers=self.headers, stream=stream)
